<?php
// +----------------------------------------------------------------------
// |  [ MAKE YOUR WORK EASIER]
// +----------------------------------------------------------------------
// | Copyright (c) 2003-2016 http://www.nbcc.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: fangrenfu <fangrenfu@126.com>
// +----------------------------------------------------------------------

namespace app\census\controller;

use app\common\access\MyAccess;
use app\common\access\MyController;
use app\common\service\Score;
use app\common\vendor\PHPExcel;

class Total extends MyController
{
    //显示信息
    public function query($page=1,$rows=20,$studentno = '%', $studentname = '%', $classno= '%', $school = '',$status='',$score='',$sort='studentno',$order='')
    {
        $result = null;
        try {
            $obj = new Score();
            $result = $obj->getList($page,$rows,$studentno,$studentname,$classno,$school,$status,$score,$sort,$order);
        } catch (\Exception $e) {
            MyAccess::throwException($e->getCode(), $e->getMessage());
        }
        return json($result);
    }


    //导出所有检索到的成绩
    public function export($studentno='%',$studentname='%',$classno='%',$school='',$status='',$score=''){
        $result=null;
        try{
            $obj=new Score();
            $result=$obj->getList(1,10000,$studentno,$studentname,$classno,$school,$status,$score,'studentno');
            $data = $result['rows'];
            $file = "总评成绩";
            $sheet = '全部';
            $title = $file;
            $template = array("studentno" => "学号", "studentname" => "姓名","classname"=>"班级","schoolname"=>"学院","statusname"=>"学籍状态",
                "guidevac"=>"职业指导","guidecom"=>"创业导论","guidejob"=>"就业指导","link"=>"职业沟通","rite"=>"职业礼仪","virtue"=>"职业操守","virtueb"=>"职业操守（本)","skill"=>"生活技能","score" => "总评");
            $string = array("studentno");
            $array[] = array("sheet" => $sheet, "title" => $title, "template" => $template, "data" => $data, "string" => $string);
            PHPExcel::export2Excel($file, $array);
        }
        catch (\Exception $e) {
            MyAccess::throwException($e->getCode(),$e->getMessage());
        }
        return json($result);
    }
} 